package com.xyc.goods.controller;

import com.xyc.global.bean.PageBean;
import com.xyc.goods.service.GoodsService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.logging.Logger;

@RestController
@RequestMapping("goods")
public class GoodsController {

    private Logger logger = Logger.getLogger("GoodsController");

    @Resource
    private GoodsService goodsService;

    @RequestMapping("pageBean")
    public PageBean returnPageBean(Integer currentPage){
        /*if (1==1){
            throw new NullPointerException("这是自定义异常");
        }*/
        if (currentPage == null){
            currentPage = 1;
        }
        logger.info("returnPageBean-->currentPage"+currentPage);
        PageBean pageBean = goodsService.queryGoodsInfo(currentPage);
        return pageBean;
    }

    @RequestMapping("pageBeanBeiTai")
    public PageBean returnPageBeanBeiTei(Integer currentPage){
        if (currentPage == null){
            currentPage = 1;
        }

        PageBean pageBean = goodsService.queryGoodsInfo(currentPage);
        return pageBean;
    }
}
